function handleToning(imageData:ImageData, init:any, R:number, G:number, B:number) {
    
    var length = imageData.data.length;
  
    for (var index = 0; index < length; index += 4) {
      imageData.data[index] = init[index] * (R * 0.01 + 1);
      imageData.data[index + 1] = init[index + 1] * (G * 0.01 + 1);
      imageData.data[index + 2] = init[index + 2] * (B * 0.01 + 1);
    }
  
    return imageData;
  }

  self.addEventListener('message', function (e) {
    const { imageData, init, R, G, B } = e.data;
    
    const newImageData = handleToning(imageData, init, R, G, B);
  
    self.postMessage({ imageData: newImageData });
  });
  // 关闭
  self.addEventListener('message', function (e) {
    if (e.data === 'close') {
      self.close();
    }
  });